package com.lqk.prototype.deepclone;

/**
 * @author lqk
 * @date 2021/12/1 18:46
 */
public class Client {
    public static void main(String[] args) throws CloneNotSupportedException {
        DeepProtoType p = new DeepProtoType();
        p.name = "jack";
        p.deepCloneableTarget = new DeepCloneableTarget("lucy","lucy的类");
        // 方式1 完成深拷贝
//        DeepProtoType p2 = (DeepProtoType)p.clone();
//        DeepProtoType p3 = (DeepProtoType)p.clone();
//
//        System.out.println("p.name="+p.name+"p.deepCloneableTarget.hashCode()="+p.deepCloneableTarget.hashCode());
//        System.out.println("p2.name="+p2.name+"p2.deepCloneableTarget.hashCode()="+p2.deepCloneableTarget.hashCode());

        // 方式2 完成深拷贝
        DeepProtoType p2 = (DeepProtoType)p.deepClone();
        DeepProtoType p3 = (DeepProtoType)p.deepClone();

        System.out.println("p.name="+p.name+"p.deepCloneableTarget.hashCode()="+p.deepCloneableTarget.hashCode());
        System.out.println("p2.name="+p2.name+"p2.deepCloneableTarget.hashCode()="+p2.deepCloneableTarget.hashCode());
        System.out.println("p3.name="+p3.name+"p2.deepCloneableTarget.hashCode()="+p3.deepCloneableTarget.hashCode());
    }
}
